<template>
  <hr />
  {{ url }}
  <button @click="show(url)">显示网址</button>
  <hr />
  <button @click="showMsg">调用全局属性与方法</button>
</template>

<script lang="ts">
import { getCurrentInstance, reactive } from "vue";
export default {
  setup() {
    //获取全局属性对象
    let globalProperties =
      getCurrentInstance()?.appContext.config.globalProperties;
    //调用全局属性与对象
    function showMsg() {
      globalProperties?.show(globalProperties.url);
    }

    return { showMsg };
  },

  //当页面挂载完成后执行的勾子
  mounted(this: any) {
    this.show(this.url);
  },
};
</script>
<style scoped>
p {
  color: red;
}
</style>
